package main

import (
	"github.com/urfave/cli"
	"gitlab.maoka-inc.com/maoka/maoka-base/log"
	"gitlab.maoka-inc.com/maokaminigame/robot-andarbahar/internal/conf"
	"net/http"
	_ "net/http/pprof"
	"os"
	"time"
)

func main() {
	// 开启pprof
	go http.ListenAndServe("0.0.0.0:6060", nil)


	app := cli.NewApp()
	app.Name = "ind_game_robot"
	app.Version = "0.1.0"
	app.Compiled = time.Now()
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "ns",
			Value: "local.yaml",
			Usage: "apollo config namespace",
		},
	}

	app.Action = startApp
	err := app.Run(os.Args)
	if err != nil {
		log.GetLogger().Fatal(err)
	}
}

// start application
func startApp(c *cli.Context) {
	// 初始化apollo配置
	namespace := c.String("ns")
	conf.Init(namespace)
	// 构建wire gen依赖
	initApp()
}
